package demo4;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/requestServlet") // 配置Servlet访问路径
public class RequestServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 向request作用域存数据
        request.setAttribute("requestMsg", "我在一次请求内的资源中有效");
        // 请求转发到requestScope.jsp
        request.getRequestDispatcher("requestScope.jsp").forward(request, response);
    }
}
